package com.yj.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yj.entity.Details;
import com.yj.service.AlipayService;

@RestController
@RequestMapping("/users")
public class PayController {
	
	    @Autowired
	     AlipayService alipayService;
	    //用于请求首页显示支付付款功能
	    @RequestMapping("/index")
	    public String hello(){
	        return "index";
	    }
	   
	    //支付成功后的异步回调，用于处理服务端业务
	    @RequestMapping("/notify_url")
	    public void notifyUrl(HttpServletRequest request)throws Exception{
	    	System.out.println("异步回调");
	        alipayService.notifyUrl(request);
	 
	    }
	 
	    //支付成功后同步回调，用于展示给用户查看
	    @RequestMapping("/return_url")
	    public String returnUrl(HttpServletRequest request)throws Exception{
	        System.out.println("同步回调");
	        return alipayService.returnUrl(request);
	    }
	 
	    //用户点击付款后请求此方法
	    @RequestMapping("/alipayTradePagePay")
	    public String alipayTradePagePay(HttpServletRequest request, HttpServletResponse response,Details detail) throws Exception{
	       return alipayService.alipayTradePagePay(request,response,detail);
	    }


}
